import { madokaPost } from "@/utils/request.ts";
import type { SignedPath, UploadCallback } from "@/typings/upload.ts";
import DriverManager from "@/utils/oss/DriverManager.ts";

export default {
  upload: async (data, file: File) => {

    // 重新请求 token
    const res = await madokaPost({ url: "/demo/oss/sign", data });
    const d = res.data as SignedPath;
    if (!d) return;

    const backData: UploadCallback = await DriverManager.getDriver(d.driver).upload(file, d)
    return backData;
  },
};
